<?php

GaAPI_Autoloader::instance()->load('GaAPI_Objects_Common_Object');

class GaAPI_Objects_Ad_Abstract extends GaAPI_Objects_Common_Object {

    public $id;
    public $url;
    public $displayUrl;
    protected $_approvalStatus;
    public $disapprovalReasons;
    public $type;


    public function  __construct() {
        GaAPI_Autoloader::instance()->load('GaAPI_Objects_Ad_ApprovalStatus');
        $this->_approvalStatus = new GaAPI_Objects_Ad_ApprovalStatus();
    }

    public function  __set($name,  $value) {
        if ($name == 'approvalStatus') {
            $this->_approvalStatus->set($value);
        }
        return $this->$name = $value;
    }


    public function &__get($name) {
        if ($name == 'approvalStatus') {
            return $this->_approvalStatus;
        }
    }

    public function getExtraFields() {
        return array();
    }

    public function  __toString() {
        $xml = '';
        $xml .= '<id>' . $this->id . '</id>';
        $xml .= '<url>' . $this->url . '</url>';
        $xml .= '<displayUrl>' . $this->displayUrl . '</displayUrl>';

        $fields = $this->getExtraFields();
        foreach ($fields as $field) {
            $xml .= ($this->$field) ? '<' . $field . '>' . $this->$field . '</' . $field. '>' : '';
        }
        
        return $xml;
    }
}